package com.zhsj.OkeHomeConsumption.ui.activity.wallet;

import android.app.DatePickerDialog;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.DatePicker;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;

import com.google.gson.Gson;
import com.zhsj.OkeHomeConsumption.R;
import com.zhsj.OkeHomeConsumption.common.Constants;
import com.zhsj.OkeHomeConsumption.common.OkeHomeConsumptionApi;
import com.zhsj.OkeHomeConsumption.empty.FormalUserInfo;
import com.zhsj.OkeHomeConsumption.empty.JsonBean;
import com.zhsj.OkeHomeConsumption.network.HttpClient;
import com.zhsj.OkeHomeConsumption.network.JsonResponseHandler;
import com.zhsj.OkeHomeConsumption.other.TimeChecker;
import com.zhsj.OkeHomeConsumption.other.URLEntity;
import com.zhsj.OkeHomeConsumption.ui.activity.wallet.packerview.OptionsPickerView;
import com.zhsj.OkeHomeConsumption.utils.GetJsonDataUtil;
import com.zhsj.OkeHomeConsumption.utils.JsonUtils;
import com.zhsj.OkeHomeConsumption.utils.LogUtils;
import com.zhsj.OkeHomeConsumption.utils.SignUtil;

import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 * Created by zwj on 2017/10/15.
 * 开通钱包 填写基本资料
 */

public class OpenWalletMessageFragment extends BaseFragment implements View.OnClickListener{

    /**
     * 计时器
     */
    private TimeChecker timeChecker = null;
    /**
     *
     * 实例化ProgressDrawableAlertDialog
     */
    private ProgressDrawableAlertDialog pDialogUtils = null;

    //左标提
    private TextView topbar_textview_leftitle;
    //标题
    private TextView topbar_textview_title;

    /**
     * 个人钱包
     */

    //证件号码
    private ClearEditText idcard_edit;
    private String idcardStr;
    //有效期限
    private LinearLayout idcard_date_linear;
    private View idcard_date_view;
    private TextView idcard_date_edit;
    private String idcard_dateStr;
    //永久
    private CheckBox idcard_date_CheckBox;
    //非永久
    private CheckBox idcard_date_isnot_CheckBox;
    //真实姓名--法人姓名
    private ClearEditText name_edit;
    private String nameStr;
    //职业类型
    private Spinner professional_type;
    private String professionalStr;
    //选择地区
    private TextView province_text;
    private String provinceStr;
    private String cityStr;
    private String zoneStr;
    //联系地址
    private ClearEditText area_edit;
    private String areaStr;
    //提款密码
    private ClearEditText password_edit;
    private String passwordStr;
    //重复提款密码
    private ClearEditText repassword_edit;
    private String repasswordStr;
    //下一步
    private TextView next;

    private FormalUserInfo userInfo;
    private String mToken;
    private String mPhone;


    /**
     * 企业钱包
     */
    //身份证号码
    private ClearEditText idcard_enterprise_edit;
    private String idcardEnterpriseStr;
    //企业身份证有效期限
    private LinearLayout idcard_date_enterprise_linear;
    private View idcard_date_enterprise_view;
    private TextView idcard_date_enterprise_edit;
    private String idcardDateEnterpriseStr;
    //永久
    private CheckBox isEnterpriseTime_CheckBox;
    //非永久
    private CheckBox isEnterpriseTime_isnot_CheckBox;
    private boolean isEnterpriseTime = false;
    private String type_expidcard = "0";
    //法人姓名
    private ClearEditText name_enterprise_edit;
    private String nameEnterpriseStr;
    //企业名称
    private ClearEditText enterprise_name_edit;
    private String enterpriseNameStr;
    //企业地址
    private TextView province_enterprise_text;
    private String provinceEnterpriseStr;
    private String cityEnterpriseStr;
    private String zoneEnterpriseStr;
//    private String province_enterpriseStr;
    //企业详细地址
    private ClearEditText area_enterprise_edit;
    private String area_enterpriseStr;
    //经营范围
    private ClearEditText enterprise_business_scope_edit;
    private String enterpriseBusinessScopeStr;
    //营业执照类型
    private Spinner business_license_type;
    private String businessLicenseStr = "0";
    //组织机构代码总
    private LinearLayout enterprise_org_code_linear;
    //营业执照号码
    private ClearEditText business_license_number_edit;
    private String businessLicenseNumberStr;
    //选择营业执照有效期
    private LinearLayout business_license_number_time_linear;
    private View business_license_number_time_view;
    private TextView business_license_number_time_text;
    private String businessLicenseNumberTimeStr;
    //永久
    private CheckBox isLicenseTime_CheckBox;
    //非永久
    private CheckBox isLicenseTime_isnot_CheckBox;
    private boolean isLicenseTime = false;
    private String type_explicense = "0";
    //企业注册类型
    private Spinner enterprise_registration_type;
    private String enterpriseRegistrationStr = "0";


    //企业开户所在地
    private TextView enterprise_account_text;
    private String provinceAccountStr;
    private String cityAccountStr;
//    private String enterpriseAccountStr;
    //开户行
    private Spinner enterprise_account_type;
    private String enterpriseAccountTypeStr;
    //支行名称
    private ClearEditText enterprise_account_name_edit;
    private String enterpriseAccount_nameStr;
    //组织机构代码
    private ClearEditText enterprise_org_code_edit;
    private String enterprise_org_codeStr;
    //组织机构代码有效期
    private TextView exp_orgcode_enterprise_text;
    private String exp_orgcode_enterpriseStr;
    //银行卡号
    private ClearEditText bank_number_edit;
    private String bankNumberStr;
    //企业提款密码
    private ClearEditText password_enterprise_edit;
    private String password_enterpriseStr;
    //重复企业提款密码
    private ClearEditText repassword_enterprise_edit;
    private String repassword_enterpriseStr;
    //企业--下一步
    private TextView next_enterprise;

    /**
     * 整体布局
     */
    //个人模块
    private LinearLayout wallet_message_individual_linear;
    //企业模块
    private LinearLayout wallet_message_enterprise_linear;

    //判断选择时间的地方
    private int isUse;

    //1开通钱包  2修改信息
    private int tag = 1;
    //用户所属商户号
    private String oid_partner;
    //钱包状态
    private String stat_user;
    //证件号码
    private String no_idcard;
    //姓名
    private String name_user;
    //是否是企业钱包--有值是企业  空是个人
    private String typeregister;

    public static OpenWalletMessageFragment newInstance(String type_register, FormalUserInfo userInfo, String token, String phone, String oid_partner, String stat_user, String name_user, String no_idcard, int tag) {

        Bundle args = new Bundle();
        OpenWalletMessageFragment fragment = new OpenWalletMessageFragment();
        args.putSerializable("userInfo",userInfo);
        args.putString("token", token);
        args.putString("phone", phone);
        args.putString("type_register", type_register);
        args.putString("oid_partner", oid_partner);
        args.putString("stat_user", stat_user);
        args.putString("name_user", name_user);
        args.putString("no_idcard", no_idcard);
        args.putInt("tag", tag);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        userInfo = (FormalUserInfo) getArguments().getSerializable("userInfo");
        mToken = getArguments().getString("token");
        mPhone = getArguments().getString("phone");
        oid_partner = getArguments().getString("oid_partner");
        stat_user = getArguments().getString("stat_user");
        name_user = getArguments().getString("name_user");
        no_idcard = getArguments().getString("no_idcard");
        typeregister = getArguments().getString("type_register");
        tag = getArguments().getInt("tag");
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_openwallet_message, container, false);
        initView(view);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initListener();
        judgmentIdentity();
        professionalType();
        businessLicenseType();
        enterpriseType();
        enterpriseAccountType();
        initJsonData();
    }

    /**
     * 判断身份
     */
    private void judgmentIdentity(){
        if (userInfo != null){

                //个人身份
                wallet_message_enterprise_linear.setVisibility(View.GONE);
                wallet_message_individual_linear.setVisibility(View.VISIBLE);

        }
    }


    private void initView(View view){
        final Calendar ca = Calendar.getInstance();
        mYear = ca.get(Calendar.YEAR);
        mMonth = ca.get(Calendar.MONTH);
        mDay = ca.get(Calendar.DAY_OF_MONTH);
        topbar_textview_leftitle = (TextView) view.findViewById(R.id.topbar_textview_leftitle);
        topbar_textview_leftitle.setVisibility(View.VISIBLE);
        topbar_textview_title = (TextView) view.findViewById(R.id.topbar_textview_title);
        topbar_textview_title.setText("开通钱包");
        next = (TextView) view.findViewById(R.id.next);
        idcard_edit = (ClearEditText) view.findViewById(R.id.idcard_edit);
        name_edit = (ClearEditText) view.findViewById(R.id.name_edit);
        professional_type = (Spinner) view.findViewById(R.id.professional_type);
        idcard_date_edit = (TextView) view.findViewById(R.id.idcard_date_edit);
        area_edit = (ClearEditText) view.findViewById(R.id.area_edit);
        password_edit = (ClearEditText) view.findViewById(R.id.password_edit);
        repassword_edit = (ClearEditText) view.findViewById(R.id.repassword_edit);
        province_text = (TextView) view.findViewById(R.id.province_text);
        enterprise_name_edit = (ClearEditText) view.findViewById(R.id.enterprise_name_edit);
        enterprise_business_scope_edit = (ClearEditText) view.findViewById(R.id.enterprise_business_scope_edit);
        business_license_type = (Spinner) view.findViewById(R.id.business_license_type);
        business_license_number_edit = (ClearEditText) view.findViewById(R.id.business_license_number_edit);
        business_license_number_time_text = (TextView) view.findViewById(R.id.business_license_number_time_text);
        enterprise_registration_type = (Spinner) view.findViewById(R.id.enterprise_registration_type);
        enterprise_account_text = (TextView) view.findViewById(R.id.enterprise_account_text);
        enterprise_account_type = (Spinner) view.findViewById(R.id.enterprise_account_type);
        enterprise_account_name_edit = (ClearEditText) view.findViewById(R.id.enterprise_account_name_edit);
        bank_number_edit = (ClearEditText) view.findViewById(R.id.bank_number_edit);
        idcard_date_enterprise_edit = (TextView) view.findViewById(R.id.idcard_date_enterprise_edit);
        idcard_enterprise_edit = (ClearEditText) view.findViewById(R.id.idcard_enterprise_edit);
        name_enterprise_edit = (ClearEditText) view.findViewById(R.id.name_enterprise_edit);
        area_enterprise_edit = (ClearEditText) view.findViewById(R.id.area_enterprise_edit);
        province_enterprise_text = (TextView) view.findViewById(R.id.province_enterprise_text);
        password_enterprise_edit = (ClearEditText) view.findViewById(R.id.password_enterprise_edit);
        repassword_enterprise_edit = (ClearEditText) view.findViewById(R.id.repassword_enterprise_edit);
        isEnterpriseTime_CheckBox = (CheckBox) view.findViewById(R.id.isEnterpriseTime_CheckBox);
        next_enterprise = (TextView) view.findViewById(R.id.next_enterprise);
        wallet_message_individual_linear = (LinearLayout) view.findViewById(R.id.wallet_message_individual_linear);
        wallet_message_enterprise_linear = (LinearLayout) view.findViewById(R.id.wallet_message_enterprise_linear);
        enterprise_org_code_edit = (ClearEditText) view.findViewById(R.id.enterprise_org_code_edit);
        exp_orgcode_enterprise_text = (TextView) view.findViewById(R.id.exp_orgcode_enterprise_text);
        isEnterpriseTime_isnot_CheckBox = (CheckBox) view.findViewById(R.id.isEnterpriseTime_isnot_CheckBox);
        isEnterpriseTime_isnot_CheckBox.setOnClickListener(this);
        isEnterpriseTime_isnot_CheckBox.setChecked(true);
        isLicenseTime_CheckBox = (CheckBox) view.findViewById(R.id.isLicenseTime_CheckBox);
        isLicenseTime_CheckBox.setOnClickListener(this);
        isLicenseTime_isnot_CheckBox = (CheckBox) view.findViewById(R.id.isLicenseTime_isnot_CheckBox);
        isLicenseTime_isnot_CheckBox.setOnClickListener(this);
        isLicenseTime_isnot_CheckBox.setChecked(true);
        idcard_date_enterprise_linear = (LinearLayout) view.findViewById(R.id.idcard_date_enterprise_linear);
        idcard_date_enterprise_view = view.findViewById(R.id.idcard_date_enterprise_view);
        business_license_number_time_linear = (LinearLayout) view.findViewById(R.id.business_license_number_time_linear);
        business_license_number_time_view = view.findViewById(R.id.business_license_number_time_view);
        enterprise_org_code_linear = (LinearLayout) view.findViewById(R.id.enterprise_org_code_linear);
        idcard_date_CheckBox = (CheckBox) view.findViewById(R.id.idcard_date_CheckBox);
        idcard_date_CheckBox.setOnClickListener(this);
        idcard_date_isnot_CheckBox = (CheckBox) view.findViewById(R.id.idcard_date_isnot_CheckBox);
        idcard_date_isnot_CheckBox.setOnClickListener(this);
        idcard_date_isnot_CheckBox.setChecked(true);
        idcard_date_linear = (LinearLayout) view.findViewById(R.id.idcard_date_linear);
        idcard_date_view = view.findViewById(R.id.idcard_date_view);

        if ("1".equals(stat_user) || "2".equals(stat_user)){
            idcard_edit.setText(no_idcard);
            idcard_edit.setFocusable(false);
            idcard_edit.setEnabled(false);
            name_edit.setText(name_user);
            name_edit.setFocusable(false);
            name_edit.setEnabled(false);
        }
    }

    private void initListener(){
        timeChecker = new TimeChecker(TimeOutHandler.timeOutHandler, Constants.TIME_OUT);
        pDialogUtils = new ProgressDrawableAlertDialog(_mActivity);
        topbar_textview_leftitle.setOnClickListener(this);
        next.setOnClickListener(this);
        idcard_date_edit.setOnClickListener(this);
        province_text.setOnClickListener(this);
        business_license_number_time_text.setOnClickListener(this);
        enterprise_account_text.setOnClickListener(this);
        idcard_date_enterprise_edit.setOnClickListener(this);
        province_enterprise_text.setOnClickListener(this);
        isEnterpriseTime_CheckBox.setOnClickListener(this);
        next_enterprise.setOnClickListener(this);
        exp_orgcode_enterprise_text.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.topbar_textview_leftitle:
                _mActivity.onBackPressed();
                break;
            case R.id.province_text:
                //选择所属地区
                ShowPickerView();
                break;
            case R.id.idcard_date_CheckBox:
                //个人证件有效期--永久
                if (idcard_date_CheckBox.isChecked()){
                    type_expidcard = "1";
                    idcard_date_isnot_CheckBox.setChecked(false);
                    idcard_date_linear.setVisibility(View.GONE);
                    idcard_date_view.setVisibility(View.GONE);
                }else {
                    type_expidcard = "0";
                    idcard_date_isnot_CheckBox.setChecked(true);
                    idcard_date_linear.setVisibility(View.VISIBLE);
                    idcard_date_view.setVisibility(View.VISIBLE);
                }
                break;
            case R.id.idcard_date_isnot_CheckBox:
                //个人证件有效期--非永久
                if (idcard_date_isnot_CheckBox.isChecked()){
                    type_expidcard = "0";
                    idcard_date_CheckBox.setChecked(false);
                    idcard_date_linear.setVisibility(View.VISIBLE);
                    idcard_date_view.setVisibility(View.VISIBLE);
                }else {
                    type_expidcard = "1";
                    idcard_date_CheckBox.setChecked(true);
                    idcard_date_linear.setVisibility(View.GONE);
                    idcard_date_view.setVisibility(View.GONE);
                }
                break;
            case R.id.next:
                next();
                break;
            case R.id.idcard_date_edit:
                //选择有效期时间
                isUse = 1;
                new DatePickerDialog(getActivity(), mdateListener, mYear, mMonth, mDay).show();
                break;
            case R.id.idcard_date_enterprise_edit:
                //选择有效期时间--企业
                isUse = 2;
                new DatePickerDialog(getActivity(), mdateListener, mYear, mMonth, mDay).show();
                break;
            case R.id.province_enterprise_text:
                //企业地址选择
                ShowPickerView();
                break;
            case R.id.business_license_number_time_text:
                //营业执照有效期
                isUse = 3;
                new DatePickerDialog(getActivity(), mdateListener, mYear, mMonth, mDay).show();
                break;
            case R.id.enterprise_account_text:
                //企业开户所在地
                ShowPickerTwoView();
                break;
            case R.id.isEnterpriseTime_CheckBox:
                //企业--证件有效期--永久
                if (isEnterpriseTime_CheckBox.isChecked()){
                    type_expidcard = "1";
                    isEnterpriseTime_isnot_CheckBox.setChecked(false);
                    idcard_date_enterprise_linear.setVisibility(View.GONE);
                    idcard_date_enterprise_view.setVisibility(View.GONE);
                }else {
                    type_expidcard = "0";
                    isEnterpriseTime_isnot_CheckBox.setChecked(true);
                    idcard_date_enterprise_linear.setVisibility(View.VISIBLE);
                    idcard_date_enterprise_view.setVisibility(View.VISIBLE);
                }
                break;
            case R.id.isEnterpriseTime_isnot_CheckBox:
                //企业--证件有效期--非永久
                if (isEnterpriseTime_isnot_CheckBox.isChecked()){
                    type_expidcard = "0";
                    isEnterpriseTime_CheckBox.setChecked(false);
                    idcard_date_enterprise_linear.setVisibility(View.VISIBLE);
                    idcard_date_enterprise_view.setVisibility(View.VISIBLE);
                }else {
                    type_expidcard = "1";
                    isEnterpriseTime_CheckBox.setChecked(true);
                    idcard_date_enterprise_linear.setVisibility(View.GONE);
                    idcard_date_enterprise_view.setVisibility(View.GONE);
                }
                break;
            case R.id.isLicenseTime_CheckBox:
                //企业--营业执照--永久
                if (isLicenseTime_CheckBox.isChecked()) {
                    type_explicense = "1";
                    isLicenseTime_isnot_CheckBox.setChecked(false);
                    business_license_number_time_linear.setVisibility(View.GONE);
                    business_license_number_time_view.setVisibility(View.GONE);
                }else {
                    type_explicense = "0";
                    isLicenseTime_isnot_CheckBox.setChecked(true);
                    business_license_number_time_linear.setVisibility(View.VISIBLE);
                    business_license_number_time_view.setVisibility(View.VISIBLE);
                }
                break;
            case R.id.isLicenseTime_isnot_CheckBox:
                //企业--营业执照--非永久
                if (isLicenseTime_isnot_CheckBox.isChecked()) {
                    type_explicense = "0";
                    isLicenseTime_CheckBox.setChecked(false);
                    business_license_number_time_linear.setVisibility(View.VISIBLE);
                    business_license_number_time_view.setVisibility(View.VISIBLE);
                }else {
                    type_explicense = "1";
                    isLicenseTime_CheckBox.setChecked(true);
                    business_license_number_time_linear.setVisibility(View.GONE);
                    business_license_number_time_view.setVisibility(View.GONE);
                }
                break;
            case R.id.next_enterprise:
                //企业--下一步
                nextEnterprise();
                break;
            case R.id.exp_orgcode_enterprise_text:
                //组织机构有效期
                isUse = 4;
                new DatePickerDialog(getActivity(), mdateListener, mYear, mMonth, mDay).show();
                break;
        }
    }

    /**
     * 验证个人信息 -- 个人
     * @param sign_type 签名方式 RSA
     * @param user_id 用户id
     * @param name_user 姓名
     * @param type_idcard 证件类型 0身份证
     * @param no_idcard 证件号
     * @param exp_idcard 身份证有效期 YYYYMMDD格式
     * @param pwd_pay 密码
     * @param addr_conn 详细地址
     * @param oid_job 职业类别
     * @param token 授权码
     * @param addr_pro 省级地址
     * @param addr_city 市级地址
     * @param addr_dist 区级地址
     * @param risk_item 风险控制参数
     * @param type_expidcard 0：非永久
     * @param flag_auth 3 三类账户认证
     */
    public void checkUserMessage(String sign_type, String user_id, String name_user, String type_idcard, String no_idcard, String exp_idcard,
                                 String pwd_pay, String addr_conn, String oid_job, String token, String addr_pro,
                                 String addr_city, String addr_dist, String risk_item, String type_expidcard, String flag_auth, String mobBind) {
        // post传参使用的HashMap
        HashMap<String, String> paramMaps = new HashMap<String, String>();
        // 生成sign值所使用的HashMap
        HashMap<String, String> mSendCodeHashMap = new HashMap<String, String>();
//        mSendCodeHashMap.put("token", Constants.TOKEN);
        mSendCodeHashMap.put("v", Constants.APPVERSION);
        mSendCodeHashMap.put("t", Constants.TIME);
        mSendCodeHashMap.put("deviceId", URLEntity.getInstance().getImei());
        mSendCodeHashMap.put("platform", Constants.PLAFORM);
        mSendCodeHashMap.put("deviceToken", Constants.DEVICETOKEN);
        mSendCodeHashMap.put("client", Constants.CLIENT);
        mSendCodeHashMap.put("sign_type", sign_type);
        mSendCodeHashMap.put("user_id", user_id);
        mSendCodeHashMap.put("name_user", name_user);
        mSendCodeHashMap.put("type_idcard", type_idcard);
        mSendCodeHashMap.put("no_idcard", no_idcard);
        mSendCodeHashMap.put("pwd_pay", pwd_pay);
        mSendCodeHashMap.put("addr_conn", addr_conn);
        mSendCodeHashMap.put("oid_job", oid_job);
        mSendCodeHashMap.put("token", token);
        mSendCodeHashMap.put("addr_pro", addr_pro);
        mSendCodeHashMap.put("addr_city", addr_city);
        mSendCodeHashMap.put("addr_dist", addr_dist);
        mSendCodeHashMap.put("risk_item", risk_item);
        mSendCodeHashMap.put("exp_idcard", exp_idcard);
        mSendCodeHashMap.put("type_expidcard", type_expidcard);
        mSendCodeHashMap.put("flag_auth", flag_auth);
        mSendCodeHashMap.put("mobBind", mobBind);

        LogUtils.e("mSendCodeHashMap", mSendCodeHashMap.toString());
        //post 传参
        paramMaps.put("sign_type", sign_type);
        paramMaps.put("user_id", user_id);
        paramMaps.put("name_user", name_user);
        paramMaps.put("type_idcard", type_idcard);
        paramMaps.put("no_idcard", no_idcard);
        paramMaps.put("pwd_pay", pwd_pay);
        paramMaps.put("addr_conn", addr_conn);
        paramMaps.put("oid_job", oid_job);
        paramMaps.put("token", token);
        paramMaps.put("addr_pro", addr_pro);
        paramMaps.put("addr_city", addr_city);
        paramMaps.put("addr_dist", addr_dist);
        paramMaps.put("risk_item", risk_item);
        paramMaps.put("exp_idcard", exp_idcard);
        paramMaps.put("type_expidcard", type_expidcard);
        paramMaps.put("flag_auth", flag_auth);
        paramMaps.put("mobBind", mobBind);

        // 网络计时器及线程
        TimeOutHandler.pDialogUtils = pDialogUtils;
        pDialogUtils.show();
        timeChecker.start();
        // 获取sign签名
        Constants.SIGN = SignUtil.getInstance().getSign(mSendCodeHashMap);
        LogUtils.e("mSendCodeHashMap", SignUtil.getInstance().getSign(mSendCodeHashMap));
        HttpClient.post(OkeHomeConsumptionApi.WALLET_USERMESSAGE_ISOK, paramMaps, new JsonResponseHandler() {

            @Override
            public void onSuccess(int statusCode, String content) {
                // TODO Auto-generated method stub
                super.onSuccess(statusCode, content);
                timeChecker.check();
                pDialogUtils.dismiss();
                TimeOutHandler.pDialogUtils = null;
                try {
                    LogUtils.e("content_验证用户开户信息", "content=" + content);
                    JSONTokener jsonT = new JSONTokener(content);
                    JSONObject jsonOBJ = (JSONObject) jsonT.nextValue();
                    String code = jsonOBJ.optString("code");
                    String message = jsonOBJ.optString("message");
                    if (code.equals("N000000")) {
                        // 数据对接正常
                        JSONObject jsonObject = jsonOBJ.optJSONObject("data");
                        JSONObject data = jsonObject.optJSONObject("data");
                        String ret_msg = data.optString("ret_msg");
                        String ret_code = data.optString("ret_code");
                        if ("0000".equals(ret_code)) {
                            startForResult(OpenWalletIDImageFragment.newInstance(typeregister, userInfo),1);
                        }else {
                            showShortToast(ret_msg + "");
                        }
                    } else if (code.equals(Constants.STATUSTOKENERROR)) {
                        if (!message.equals("null")) {
                            showShortToast(message);
                        }
                    } else {
                        if (!message.equals("null")) {
                            showShortToast(message);
                        }
                    }
                } catch (Exception ex) {
                    LogUtils.e("DresserPartnerRegisterPost", "失败 ");
                }
            }

            @Override
            public void onFailure(Throwable e) {
                // TODO Auto-generated method stub
                super.onFailure(e);
                timeChecker.check();
                pDialogUtils.dismiss();
                TimeOutHandler.pDialogUtils = null;
                LogUtils.e("onFailure", "" + e.toString());
            }
        });
    }

    /**
     * 修改个人信息 -- 个人
     * @param sign_type 签名方式 RSA
     * @param user_id 用户id
     * @param name_user 姓名
     * @param type_idcard 证件类型 0身份证
     * @param no_idcard 证件号
     * @param exp_idcard 身份证有效期 YYYYMMDD格式
     * @param pwd_pay 密码
     * @param addr_conn 详细地址
     * @param oid_job 职业类别
     * @param token 授权码
     * @param addr_pro 省级地址
     * @param addr_city 市级地址
     * @param addr_dist 区级地址
     * @param risk_item 风险控制参数
     * @param type_expidcard 0：非永久
     * @param flag_auth 3 三类账户认证
     */
    public void modifykUserMessage(String oid_partner, String sign_type, String user_id, String name_user, String type_idcard, String no_idcard, String exp_idcard,
                                   String pwd_pay, String addr_conn, String oid_job, String token, String addr_pro,
                                   String addr_city, String addr_dist, String risk_item, String type_expidcard, String flag_auth) {
        // post传参使用的HashMap
        HashMap<String, String> paramMaps = new HashMap<String, String>();
        // 生成sign值所使用的HashMap
        HashMap<String, String> mSendCodeHashMap = new HashMap<String, String>();
//        mSendCodeHashMap.put("token", Constants.TOKEN);
        mSendCodeHashMap.put("v", Constants.APPVERSION);
        mSendCodeHashMap.put("t", Constants.TIME);
        mSendCodeHashMap.put("deviceId", URLEntity.getInstance().getImei());
        mSendCodeHashMap.put("platform", Constants.PLAFORM);
        mSendCodeHashMap.put("deviceToken", Constants.DEVICETOKEN);
        mSendCodeHashMap.put("client", Constants.CLIENT);
        mSendCodeHashMap.put("sign_type", sign_type);
        mSendCodeHashMap.put("user_id", user_id);
        mSendCodeHashMap.put("name_user", name_user);
        mSendCodeHashMap.put("type_idcard", type_idcard);
        mSendCodeHashMap.put("no_idcard", no_idcard);
        mSendCodeHashMap.put("pwd_pay", pwd_pay);
        mSendCodeHashMap.put("addr_conn", addr_conn);
        mSendCodeHashMap.put("oid_job", oid_job);
        mSendCodeHashMap.put("token", token);
        mSendCodeHashMap.put("addr_pro", addr_pro);
        mSendCodeHashMap.put("addr_city", addr_city);
        mSendCodeHashMap.put("addr_dist", addr_dist);
        mSendCodeHashMap.put("risk_item", risk_item);
        mSendCodeHashMap.put("exp_idcard", exp_idcard);
        mSendCodeHashMap.put("type_expidcard", type_expidcard);
        mSendCodeHashMap.put("flag_auth", flag_auth);
        mSendCodeHashMap.put("oid_partner", oid_partner);

        LogUtils.e("mSendCodeHashMap", mSendCodeHashMap.toString());
        //post 传参
        paramMaps.put("sign_type", sign_type);
        paramMaps.put("user_id", user_id);
        paramMaps.put("name_user", name_user);
        paramMaps.put("type_idcard", type_idcard);
        paramMaps.put("no_idcard", no_idcard);
        paramMaps.put("pwd_pay", pwd_pay);
        paramMaps.put("addr_conn", addr_conn);
        paramMaps.put("oid_job", oid_job);
        paramMaps.put("token", token);
        paramMaps.put("addr_pro", addr_pro);
        paramMaps.put("addr_city", addr_city);
        paramMaps.put("addr_dist", addr_dist);
        paramMaps.put("risk_item", risk_item);
        paramMaps.put("exp_idcard", exp_idcard);
        paramMaps.put("type_expidcard", type_expidcard);
        paramMaps.put("flag_auth", flag_auth);
        paramMaps.put("oid_partner", oid_partner);

        // 网络计时器及线程
        TimeOutHandler.pDialogUtils = pDialogUtils;
        pDialogUtils.show();
        timeChecker.start();
        // 获取sign签名
        Constants.SIGN = SignUtil.getInstance().getSign(mSendCodeHashMap);
        LogUtils.e("mSendCodeHashMap", SignUtil.getInstance().getSign(mSendCodeHashMap));
        HttpClient.post(OkeHomeConsumptionApi.WALLET_USERMESSAGE_MODIFY, paramMaps, new JsonResponseHandler() {

            @Override
            public void onSuccess(int statusCode, String content) {
                // TODO Auto-generated method stub
                super.onSuccess(statusCode, content);
                timeChecker.check();
                pDialogUtils.dismiss();
                TimeOutHandler.pDialogUtils = null;
                try {
                    LogUtils.e("content_验证用户开户信息", "content=" + content);
                    JSONTokener jsonT = new JSONTokener(content);
                    JSONObject jsonOBJ = (JSONObject) jsonT.nextValue();
                    String code = jsonOBJ.optString("code");
                    String message = jsonOBJ.optString("message");
                    if (code.equals("N000000")) {
                        // 数据对接正常
                        JSONObject jsonObject = jsonOBJ.optJSONObject("data");
                        JSONObject data = jsonObject.optJSONObject("data");
                        String ret_msg = data.optString("ret_msg");
                        String ret_code = data.optString("ret_code");
                        if ("0000".equals(ret_code)) {
                            startForResult(OpenWalletIDImageFragment.newInstance(typeregister, userInfo),1);
                        }else {
                            showShortToast(ret_msg + "");
                        }
                    } else if (code.equals(Constants.STATUSTOKENERROR)) {
                        if (!message.equals("null")) {
                            showShortToast(message);
                        }
                    } else {
                        if (!message.equals("null")) {
                            showShortToast(message);
                        }
                    }
                } catch (Exception ex) {
                    LogUtils.e("DresserPartnerRegisterPost", "失败 ");
                }
            }

            @Override
            public void onFailure(Throwable e) {
                // TODO Auto-generated method stub
                super.onFailure(e);
                timeChecker.check();
                pDialogUtils.dismiss();
                TimeOutHandler.pDialogUtils = null;
                LogUtils.e("onFailure", "" + e.toString());
            }
        });
    }

    /**
     * 修改个人信息 -- 个人
     * @param sign_type 签名方式 RSA
     * @param user_id 用户id
     * @param exp_idcard 身份证有效期 YYYYMMDD格式
     * @param pwd_pay 密码
     * @param addr_conn 详细地址
     * @param oid_job 职业类别
     * @param token 授权码
     * @param addr_pro 省级地址
     * @param addr_city 市级地址
     * @param addr_dist 区级地址
     * @param risk_item 风险控制参数
     * @param type_expidcard 0：非永久
     * @param flag_auth 3 三类账户认证
     */
    public void modifykMessage(String oid_partner, String sign_type, String user_id, String exp_idcard,
                               String pwd_pay, String addr_conn, String oid_job, String token, String addr_pro,
                               String addr_city, String addr_dist, String risk_item, String type_expidcard, String flag_auth) {
        // post传参使用的HashMap
        HashMap<String, String> paramMaps = new HashMap<String, String>();
        // 生成sign值所使用的HashMap
        HashMap<String, String> mSendCodeHashMap = new HashMap<String, String>();
//        mSendCodeHashMap.put("token", Constants.TOKEN);
        mSendCodeHashMap.put("v", Constants.APPVERSION);
        mSendCodeHashMap.put("t", Constants.TIME);
        mSendCodeHashMap.put("deviceId", URLEntity.getInstance().getImei());
        mSendCodeHashMap.put("platform", Constants.PLAFORM);
        mSendCodeHashMap.put("deviceToken", Constants.DEVICETOKEN);
        mSendCodeHashMap.put("client", Constants.CLIENT);
        mSendCodeHashMap.put("sign_type", sign_type);
        mSendCodeHashMap.put("user_id", user_id);
        mSendCodeHashMap.put("pwd_pay", pwd_pay);
        mSendCodeHashMap.put("addr_conn", addr_conn);
        mSendCodeHashMap.put("oid_job", oid_job);
        mSendCodeHashMap.put("token", token);
        mSendCodeHashMap.put("addr_pro", addr_pro);
        mSendCodeHashMap.put("addr_city", addr_city);
        mSendCodeHashMap.put("addr_dist", addr_dist);
        mSendCodeHashMap.put("risk_item", risk_item);
        mSendCodeHashMap.put("exp_idcard", exp_idcard);
        mSendCodeHashMap.put("type_expidcard", type_expidcard);
        mSendCodeHashMap.put("flag_auth", flag_auth);
        mSendCodeHashMap.put("oid_partner", oid_partner);

        LogUtils.e("mSendCodeHashMap", mSendCodeHashMap.toString());
        //post 传参
        paramMaps.put("sign_type", sign_type);
        paramMaps.put("user_id", user_id);
        paramMaps.put("pwd_pay", pwd_pay);
        paramMaps.put("addr_conn", addr_conn);
        paramMaps.put("oid_job", oid_job);
        paramMaps.put("token", token);
        paramMaps.put("addr_pro", addr_pro);
        paramMaps.put("addr_city", addr_city);
        paramMaps.put("addr_dist", addr_dist);
        paramMaps.put("risk_item", risk_item);
        paramMaps.put("exp_idcard", exp_idcard);
        paramMaps.put("type_expidcard", type_expidcard);
        paramMaps.put("flag_auth", flag_auth);
        paramMaps.put("oid_partner", oid_partner);

        // 网络计时器及线程
        TimeOutHandler.pDialogUtils = pDialogUtils;
        pDialogUtils.show();
        timeChecker.start();
        // 获取sign签名
        Constants.SIGN = SignUtil.getInstance().getSign(mSendCodeHashMap);
        LogUtils.e("mSendCodeHashMap", SignUtil.getInstance().getSign(mSendCodeHashMap));
        HttpClient.post(OkeHomeConsumptionApi.WALLET_USERMESSAGE_MODIFY, paramMaps, new JsonResponseHandler() {

            @Override
            public void onSuccess(int statusCode, String content) {
                // TODO Auto-generated method stub
                super.onSuccess(statusCode, content);
                timeChecker.check();
                pDialogUtils.dismiss();
                TimeOutHandler.pDialogUtils = null;
                try {
                    LogUtils.e("content_验证用户开户信息", "content=" + content);
                    JSONTokener jsonT = new JSONTokener(content);
                    JSONObject jsonOBJ = (JSONObject) jsonT.nextValue();
                    String code = jsonOBJ.optString("code");
                    String message = jsonOBJ.optString("message");
                    if (code.equals("N000000")) {
                        // 数据对接正常
                        JSONObject jsonObject = jsonOBJ.optJSONObject("data");
                        JSONObject data = jsonObject.optJSONObject("data");
                        String ret_msg = data.optString("ret_msg");
                        String ret_code = data.optString("ret_code");
                        if ("0000".equals(ret_code)) {
                            startForResult(OpenWalletIDImageFragment.newInstance(typeregister, userInfo),1);
                        }else {
                            showShortToast(ret_msg + "");
                        }
                    } else if (code.equals(Constants.STATUSTOKENERROR)) {
                        if (!message.equals("null")) {
                            showShortToast(message);
                        }
                    } else {
                        if (!message.equals("null")) {
                            showShortToast(message);
                        }
                    }
                } catch (Exception ex) {
                    LogUtils.e("DresserPartnerRegisterPost", "失败 ");
                }
            }

            @Override
            public void onFailure(Throwable e) {
                // TODO Auto-generated method stub
                super.onFailure(e);
                timeChecker.check();
                pDialogUtils.dismiss();
                TimeOutHandler.pDialogUtils = null;
                LogUtils.e("onFailure", "" + e.toString());
            }
        });
    }

    private void next(){
        idcardStr = idcard_edit.getText().toString().trim();
        nameStr = name_edit.getText().toString().trim();
        professionalStr = professional_type.getSelectedItem() + "";
        areaStr = area_edit.getText().toString().trim();
        passwordStr = password_edit.getText().toString().trim();
        repasswordStr = repassword_edit.getText().toString().trim();
        idcard_dateStr = idcard_date_edit.getText().toString().trim();
        if (TextUtils.isEmpty(idcardStr)){
            showShortToast("请填写证件号码");
            return;
        }
        if (TextUtils.isEmpty(nameStr)){
            showShortToast("请填写姓名");
            return;
        }
        if (TextUtils.isEmpty(areaStr)){
            showShortToast("请填写联系地址");
            return;
        }
        if (TextUtils.isEmpty(passwordStr) || TextUtils.isEmpty(repasswordStr)){
            showShortToast("请填写提款密码");
            return;
        }
        if (!passwordStr.equals(repasswordStr)){
            showShortToast("两次密码不一致");
            return;
        }

        if (tag == 1) {
            checkUserMessage("RSA", userInfo.getId() + "", nameStr, "0", idcardStr, idcard_dateStr, passwordStr,
                    areaStr, getOccupationType(professionalStr), mToken, provinceStr, cityStr, zoneStr, SubmitCaseContent(), type_expidcard, "3", mPhone);
        }else {
            if ("1".equals(stat_user) || "2".equals(stat_user)){
                modifykMessage(oid_partner, "RSA", userInfo.getId() + "", idcard_dateStr, passwordStr,
                        areaStr, getOccupationType(professionalStr), mToken, provinceStr, cityStr, zoneStr, SubmitCaseContent(), "0", "3");

            }else {
                modifykUserMessage(oid_partner, "RSA", userInfo.getId() + "", nameStr, "0", idcardStr, idcard_dateStr, passwordStr,
                        areaStr, getOccupationType(professionalStr), mToken, provinceStr, cityStr, zoneStr, SubmitCaseContent(), "0", "3");
            }
        }
    }

    /**
     * 企业下一步
     */
    private void nextEnterprise() {
        idcardEnterpriseStr = idcard_enterprise_edit.getText().toString().trim();
        idcardDateEnterpriseStr = idcard_date_enterprise_edit.getText().toString().trim();
        nameEnterpriseStr = name_enterprise_edit.getText().toString().trim();
        enterpriseNameStr = enterprise_name_edit.getText().toString().trim();
        area_enterpriseStr = area_enterprise_edit.getText().toString().trim();
        enterpriseBusinessScopeStr = enterprise_business_scope_edit.getText().toString().trim();
        businessLicenseNumberStr = business_license_number_edit.getText().toString().trim();
        businessLicenseNumberTimeStr = business_license_number_time_text.getText().toString().trim();
        bankNumberStr = bank_number_edit.getText().toString().trim();
        password_enterpriseStr = password_enterprise_edit.getText().toString().trim();
        repassword_enterpriseStr = repassword_enterprise_edit.getText().toString().trim();
        enterpriseAccountTypeStr = enterprise_account_type.getSelectedItem() + "";
        exp_orgcode_enterpriseStr = exp_orgcode_enterprise_text.getText().toString().trim();
        enterpriseAccount_nameStr = enterprise_account_name_edit.getText().toString().trim();
        enterprise_org_codeStr = enterprise_org_code_edit.getText().toString().trim();
        if (TextUtils.isEmpty(idcardEnterpriseStr)) {
            showShortToast("请填写证件号码");
            return;
        }

        if (TextUtils.isEmpty(nameEnterpriseStr)) {
            showShortToast("请填写法人姓名");
            return;
        }
        if (TextUtils.isEmpty(enterpriseNameStr)) {
            showShortToast("请填写企业名称");
            return;
        }
        if (TextUtils.isEmpty(area_enterpriseStr)) {
            showShortToast("请填写企业详细地址");
            return;
        }
        if (TextUtils.isEmpty(enterpriseBusinessScopeStr)) {
            showShortToast("请填写经营范围");
            return;
        }
        if (TextUtils.isEmpty(businessLicenseNumberStr)) {
            showShortToast("请填写营业执照号码");
            return;
        }
        if (TextUtils.isEmpty(enterpriseAccount_nameStr)) {
            showShortToast("请填写支行名称");
            return;
        }
//        if (TextUtils.isEmpty(enterprise_org_codeStr)) {
//            showShortToast("请填写组织机构代码");
//            return;
//        }

        if (TextUtils.isEmpty(bankNumberStr)) {
            showShortToast("请输入银行卡号");
            return;
        }
        if (TextUtils.isEmpty(password_enterpriseStr) || TextUtils.isEmpty(repassword_enterpriseStr)) {
            showShortToast("请填写提款密码");
            return;
        }
        if (!password_enterpriseStr.equals(repassword_enterpriseStr)) {
            showShortToast("两次密码不一致");
            return;
        }

        if (tag == 1) {
            checkEnterpriseMessage("RSA", userInfo.getId() + "", mToken, nameEnterpriseStr, idcardDateEnterpriseStr, type_expidcard, idcardEnterpriseStr,
                    password_enterpriseStr, provinceEnterpriseStr, provinceEnterpriseStr, cityEnterpriseStr, zoneEnterpriseStr, enterpriseBusinessScopeStr, enterpriseNameStr, businessLicenseNumberStr, businessLicenseNumberTimeStr,
                    type_explicense, enterpriseRegistrationStr, businessLicenseStr, cityAccountStr, bankNumberStr,
                    SubmitCaseContent(), mPhone, exp_orgcode_enterpriseStr, enterpriseAccount_nameStr, enterprise_org_codeStr, enterpriseAccountTypeStr);
        }else {
            modifyEnterpriseMessage(oid_partner, "RSA", userInfo.getId() + "", mToken, nameEnterpriseStr, idcardDateEnterpriseStr, type_expidcard, idcardEnterpriseStr,
                    password_enterpriseStr, provinceEnterpriseStr, provinceEnterpriseStr, cityEnterpriseStr, zoneEnterpriseStr, enterpriseBusinessScopeStr, enterpriseNameStr, businessLicenseNumberStr, businessLicenseNumberTimeStr,
                    type_explicense, enterpriseRegistrationStr, businessLicenseStr, cityAccountStr, bankNumberStr,
                    SubmitCaseContent(), mPhone, exp_orgcode_enterpriseStr, enterpriseAccount_nameStr, enterprise_org_codeStr, enterpriseAccountTypeStr);
        }
    }
    /**
     * 验证企业信息
     * @param sign_type 签名方式 RSA
     * @param user_id 用户id
     * @param token 授权码
     * @param name_user 法人姓名
     * @param exp_idcard 身份证有效期 YYYYMMDD格式
     * @param type_expidcard 法人证件有效 0 非永久 1 永久
     * @param no_idcard 法人证件号
     * @param pwd_pay 支付密码
     * @param addr_unit 企业地址
     * @param addr_pro 省级地址
     * @param addr_city 市级地址
     * @param addr_dist 区级地址
     * @param busi_user 经营范围
     * @param name_unit 企业名称
     * @param num_license 营业执照号码
     * @param exp_license 营业执照有效期
     * @param type_explicense 营业执照有效期类型 0非永久 1永久
     * @param type_register 企业注册类型 0:企业 1:个体工商户 2:事业单位 3:社会团体
     * @param type_license 营业执照类型 0 普通营业执照  1多证合一营业执照（存在独立的组织机构代码证）(合证不合号)  2多证合一营业执照（不存在独立的组织机构代码证）(合证合号
     * @param city_code 开户行所在市编码
     * @param card_no 银行账号
     * @param risk_item 风险控制参数
     * @param mob_bind 绑定手机号码
     * @param exp_orgcode 组织机构代码有效期
     * @param brabank_name 支行名称
     * @param org_code 组织机构代码
     * @param bank_code 开户银行名称
     */
    public void checkEnterpriseMessage(String sign_type, String user_id, String token, String name_user,
                                       String exp_idcard, String type_expidcard, String no_idcard,
                                       String pwd_pay, String addr_unit, String addr_pro,
                                       String addr_city, String addr_dist, String busi_user, String name_unit, String num_license,
                                       String exp_license, String type_explicense, String type_register, String type_license,
                                       String city_code, String card_no, String risk_item, String mob_bind, String exp_orgcode,
                                       String brabank_name, String org_code, String bank_code) {
        // post传参使用的HashMap
        HashMap<String, String> paramMaps = new HashMap<String, String>();
        // 生成sign值所使用的HashMap
        HashMap<String, String> mSendCodeHashMap = new HashMap<String, String>();
//        mSendCodeHashMap.put("token", Constants.TOKEN);
        mSendCodeHashMap.put("v", Constants.APPVERSION);
        mSendCodeHashMap.put("t", Constants.TIME);
        mSendCodeHashMap.put("deviceId", URLEntity.getInstance().getImei());
        mSendCodeHashMap.put("platform", Constants.PLAFORM);
        mSendCodeHashMap.put("deviceToken", Constants.DEVICETOKEN);
        mSendCodeHashMap.put("client", Constants.CLIENT);

        mSendCodeHashMap.put("sign_type", sign_type);
        mSendCodeHashMap.put("user_id", user_id);
        mSendCodeHashMap.put("token", token);
        mSendCodeHashMap.put("name_user", name_user);
        mSendCodeHashMap.put("exp_idcard", exp_idcard);
        mSendCodeHashMap.put("type_expidcard", type_expidcard);
        mSendCodeHashMap.put("no_idcard", no_idcard);
        mSendCodeHashMap.put("pwd_pay", pwd_pay);
        mSendCodeHashMap.put("addr_unit", addr_unit);
        mSendCodeHashMap.put("addr_pro", addr_pro);
        mSendCodeHashMap.put("addr_city", addr_city);
        mSendCodeHashMap.put("addr_dist", addr_dist);
        mSendCodeHashMap.put("busi_user", busi_user);
        mSendCodeHashMap.put("name_unit", name_unit);
        mSendCodeHashMap.put("num_license", num_license);
        mSendCodeHashMap.put("exp_license", exp_license);
        mSendCodeHashMap.put("type_explicense", type_explicense);
        mSendCodeHashMap.put("type_register", type_register);
        mSendCodeHashMap.put("type_license", type_license);
        mSendCodeHashMap.put("city_code", city_code);
        mSendCodeHashMap.put("card_no", card_no);
        mSendCodeHashMap.put("risk_item", risk_item);
        mSendCodeHashMap.put("mob_bind", mob_bind);
        mSendCodeHashMap.put("exp_orgcode", exp_orgcode);
        mSendCodeHashMap.put("brabank_name", brabank_name);
        mSendCodeHashMap.put("org_code", org_code);
        mSendCodeHashMap.put("bank_code", bank_code);

        LogUtils.e("mSendCodeHashMap", mSendCodeHashMap.toString());
        //post 传参
        paramMaps.put("sign_type", sign_type);
        paramMaps.put("user_id", user_id);
        paramMaps.put("token", token);
        paramMaps.put("name_user", name_user);
        paramMaps.put("exp_idcard", exp_idcard);
        paramMaps.put("type_expidcard", type_expidcard);
        paramMaps.put("no_idcard", no_idcard);
        paramMaps.put("pwd_pay", pwd_pay);
        paramMaps.put("addr_unit", addr_unit);
        paramMaps.put("addr_pro", addr_pro);
        paramMaps.put("addr_city", addr_city);
        paramMaps.put("addr_dist", addr_dist);
        paramMaps.put("busi_user", busi_user);
        paramMaps.put("name_unit", name_unit);
        paramMaps.put("num_license", num_license);
        paramMaps.put("exp_license", exp_license);
        paramMaps.put("type_explicense", type_explicense);
        paramMaps.put("type_register", type_register);
        paramMaps.put("type_license", type_license);
        paramMaps.put("city_code", city_code);
        paramMaps.put("card_no", card_no);
        paramMaps.put("risk_item", risk_item);
        paramMaps.put("mob_bind", mob_bind);
        paramMaps.put("exp_orgcode", exp_orgcode);
        paramMaps.put("brabank_name", brabank_name);
        paramMaps.put("org_code", org_code);
        paramMaps.put("bank_code", bank_code);

        // 网络计时器及线程
        TimeOutHandler.pDialogUtils = pDialogUtils;
        pDialogUtils.show();
        timeChecker.start();
        // 获取sign签名
        Constants.SIGN = SignUtil.getInstance().getSign(mSendCodeHashMap);
        LogUtils.e("paramMaps", paramMaps.toString());
        HttpClient.post(OkeHomeConsumptionApi.WALLET_USERMESSAGE_ENTERPRISE_ISOK, paramMaps, new JsonResponseHandler() {

            @Override
            public void onSuccess(int statusCode, String content) {
                // TODO Auto-generated method stub
                super.onSuccess(statusCode, content);
                timeChecker.check();
                pDialogUtils.dismiss();
                TimeOutHandler.pDialogUtils = null;
                try {
                    LogUtils.e("content_验证用户开户信息", "content=" + content);
                    JSONTokener jsonT = new JSONTokener(content);
                    JSONObject jsonOBJ = (JSONObject) jsonT.nextValue();
                    String code = jsonOBJ.optString("code");
                    String message = jsonOBJ.optString("message");
                    if (code.equals("N000000")) {
                        // 数据对接正常
                        JSONObject jsonObject = jsonOBJ.optJSONObject("data");
                        JSONObject data = jsonObject.optJSONObject("data");
                        String ret_msg = data.optString("ret_msg");
                        String ret_code = data.optString("ret_code");
                        if ("0000".equals(ret_code)) {
                            startForResult(OpenWalletIDImageFragment.newInstance(typeregister, userInfo), 1);
                        }else {
                            showShortToast(ret_msg + "");
                        }
                    } else if (code.equals(Constants.STATUSTOKENERROR)) {
                        if (!message.equals("null")) {
                            showShortToast(message);
                        }
                    } else {
                        if (!message.equals("null")) {
                            showShortToast(message);
                        }
                    }
                } catch (Exception ex) {
                    LogUtils.e("DresserPartnerRegisterPost", "失败 ");
                }
            }

            @Override
            public void onFailure(Throwable e) {
                // TODO Auto-generated method stub
                super.onFailure(e);
                timeChecker.check();
                pDialogUtils.dismiss();
                TimeOutHandler.pDialogUtils = null;
                LogUtils.e("onFailure", "" + e.toString());
            }
        });
    }

    /**
     * 修改企业信息
     * @param sign_type 签名方式 RSA
     * @param user_id 用户id
     * @param token 授权码
     * @param name_user 法人姓名
     * @param exp_idcard 身份证有效期 YYYYMMDD格式
     * @param type_expidcard 法人证件有效 0 非永久 1 永久
     * @param no_idcard 法人证件号
     * @param pwd_pay 支付密码
     * @param addr_unit 企业地址
     * @param addr_pro 省级地址
     * @param addr_city 市级地址
     * @param addr_dist 区级地址
     * @param busi_user 经营范围
     * @param name_unit 企业名称
     * @param num_license 营业执照号码
     * @param exp_license 营业执照有效期
     * @param type_explicense 营业执照有效期类型 0非永久 1永久
     * @param type_register 企业注册类型 0:企业 1:个体工商户 2:事业单位 3:社会团体
     * @param type_license 营业执照类型 0 普通营业执照  1多证合一营业执照（存在独立的组织机构代码证）(合证不合号)  2多证合一营业执照（不存在独立的组织机构代码证）(合证合号
     * @param city_code 开户行所在市编码
     * @param card_no 银行账号
     * @param risk_item 风险控制参数
     * @param mob_bind 绑定手机号码
     * @param exp_orgcode 组织机构代码有效期
     * @param brabank_name 支行名称
     * @param org_code 组织机构代码
     * @param bank_code 开户银行名称
     */
    public void modifyEnterpriseMessage(String oid_partner, String sign_type, String user_id, String token, String name_user,
                                        String exp_idcard, String type_expidcard, String no_idcard,
                                        String pwd_pay, String addr_unit, String addr_pro,
                                        String addr_city, String addr_dist, String busi_user, String name_unit, String num_license,
                                        String exp_license, String type_explicense, String type_register, String type_license,
                                        String city_code, String card_no, String risk_item, String mob_bind, String exp_orgcode,
                                        String brabank_name, String org_code, String bank_code) {
        // post传参使用的HashMap
        HashMap<String, String> paramMaps = new HashMap<String, String>();
        // 生成sign值所使用的HashMap
        HashMap<String, String> mSendCodeHashMap = new HashMap<String, String>();
//        mSendCodeHashMap.put("token", Constants.TOKEN);
        mSendCodeHashMap.put("v", Constants.APPVERSION);
        mSendCodeHashMap.put("t", Constants.TIME);
        mSendCodeHashMap.put("deviceId", URLEntity.getInstance().getImei());
        mSendCodeHashMap.put("platform", Constants.PLAFORM);
        mSendCodeHashMap.put("deviceToken", Constants.DEVICETOKEN);
        mSendCodeHashMap.put("client", Constants.CLIENT);

        mSendCodeHashMap.put("sign_type", sign_type);
        mSendCodeHashMap.put("user_id", user_id);
        mSendCodeHashMap.put("token", token);
        mSendCodeHashMap.put("name_user", name_user);
        mSendCodeHashMap.put("exp_idcard", exp_idcard);
        mSendCodeHashMap.put("type_expidcard", type_expidcard);
        mSendCodeHashMap.put("no_idcard", no_idcard);
        mSendCodeHashMap.put("pwd_pay", pwd_pay);
        mSendCodeHashMap.put("addr_unit", addr_unit);
        mSendCodeHashMap.put("addr_pro", addr_pro);
        mSendCodeHashMap.put("addr_city", addr_city);
        mSendCodeHashMap.put("addr_dist", addr_dist);
        mSendCodeHashMap.put("busi_user", busi_user);
        mSendCodeHashMap.put("name_unit", name_unit);
        mSendCodeHashMap.put("num_license", num_license);
        mSendCodeHashMap.put("exp_license", exp_license);
        mSendCodeHashMap.put("type_explicense", type_explicense);
        mSendCodeHashMap.put("type_register", type_register);
        mSendCodeHashMap.put("type_license", type_license);
        mSendCodeHashMap.put("city_code", city_code);
        mSendCodeHashMap.put("card_no", card_no);
        mSendCodeHashMap.put("risk_item", risk_item);
        mSendCodeHashMap.put("mob_bind", mob_bind);
        mSendCodeHashMap.put("exp_orgcode", exp_orgcode);
        mSendCodeHashMap.put("brabank_name", brabank_name);
        mSendCodeHashMap.put("org_code", org_code);
        mSendCodeHashMap.put("bank_code", bank_code);
        mSendCodeHashMap.put("oid_partner", oid_partner);

        LogUtils.e("mSendCodeHashMap", mSendCodeHashMap.toString());
        //post 传参
        paramMaps.put("sign_type", sign_type);
        paramMaps.put("user_id", user_id);
        paramMaps.put("token", token);
        paramMaps.put("name_user", name_user);
        paramMaps.put("exp_idcard", exp_idcard);
        paramMaps.put("type_expidcard", type_expidcard);
        paramMaps.put("no_idcard", no_idcard);
        paramMaps.put("pwd_pay", pwd_pay);
        paramMaps.put("addr_unit", addr_unit);
        paramMaps.put("addr_pro", addr_pro);
        paramMaps.put("addr_city", addr_city);
        paramMaps.put("addr_dist", addr_dist);
        paramMaps.put("busi_user", busi_user);
        paramMaps.put("name_unit", name_unit);
        paramMaps.put("num_license", num_license);
        paramMaps.put("exp_license", exp_license);
        paramMaps.put("type_explicense", type_explicense);
        paramMaps.put("type_register", type_register);
        paramMaps.put("type_license", type_license);
        paramMaps.put("city_code", city_code);
        paramMaps.put("card_no", card_no);
        paramMaps.put("risk_item", risk_item);
        paramMaps.put("mob_bind", mob_bind);
        paramMaps.put("exp_orgcode", exp_orgcode);
        paramMaps.put("brabank_name", brabank_name);
        paramMaps.put("org_code", org_code);
        paramMaps.put("bank_code", bank_code);
        paramMaps.put("oid_partner", oid_partner);

        // 网络计时器及线程
        TimeOutHandler.pDialogUtils = pDialogUtils;
        pDialogUtils.show();
        timeChecker.start();
        // 获取sign签名
        Constants.SIGN = SignUtil.getInstance().getSign(mSendCodeHashMap);
        LogUtils.e("paramMaps", paramMaps.toString());
        HttpClient.post(OkeHomeConsumptionApi.WALLET_USERMESSAGE_ENTERPRISE_MODIFY, paramMaps, new JsonResponseHandler() {

            @Override
            public void onSuccess(int statusCode, String content) {
                // TODO Auto-generated method stub
                super.onSuccess(statusCode, content);
                timeChecker.check();
                pDialogUtils.dismiss();
                TimeOutHandler.pDialogUtils = null;
                try {
                    LogUtils.e("content_修改用户开户信息", "content=" + content);
                    JSONTokener jsonT = new JSONTokener(content);
                    JSONObject jsonOBJ = (JSONObject) jsonT.nextValue();
                    String code = jsonOBJ.optString("code");
                    String message = jsonOBJ.optString("message");
                    if (code.equals("N000000")) {
                        // 数据对接正常
                        JSONObject jsonObject = jsonOBJ.optJSONObject("data");
                        JSONObject data = jsonObject.optJSONObject("data");
                        String ret_msg = data.optString("ret_msg");
                        String ret_code = data.optString("ret_code");
                        if ("0000".equals(ret_code)) {
                            startForResult(OpenWalletIDImageFragment.newInstance(typeregister, userInfo), 1);
                        }else {
                            showShortToast(ret_msg + "");
                        }
                    } else if (code.equals(Constants.STATUSTOKENERROR)) {
                        if (!message.equals("null")) {
                            showShortToast(message);
                        }
                    } else {
                        if (!message.equals("null")) {
                            showShortToast(message);
                        }
                    }
                } catch (Exception ex) {
                    LogUtils.e("DresserPartnerRegisterPost", "失败 ");
                }
            }

            @Override
            public void onFailure(Throwable e) {
                // TODO Auto-generated method stub
                super.onFailure(e);
                timeChecker.check();
                pDialogUtils.dismiss();
                TimeOutHandler.pDialogUtils = null;
                LogUtils.e("onFailure", "" + e.toString());
            }
        });
    }
    @Override
    public void onFragmentResult(int requestCode, int resultCode, Bundle data) {
        super.onFragmentResult(requestCode, resultCode, data);
        switch (requestCode){
            case 1:
                if (resultCode == RESULT_OK){
                    setFragmentResult(RESULT_OK, new Bundle());
                    _mActivity.onBackPressed();
                }
        }
    }
    private List<HashMap<String, String>> hashMapLists;
    /**
     * 风控参数
     * @return
     */
    public String SubmitCaseContent() {
        //设置日期格式
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String content = "";
        if (hashMapLists == null)
            hashMapLists = new ArrayList<>();
        if (hashMapLists.size() > 0)
            hashMapLists.clear();

            HashMap<String, String> map = new HashMap<>();
            map.put("user_info_dt_register",df.format(new Date()));

            hashMapLists.add(map);

        if (hashMapLists == null) {
            return "";
        }
        StringBuilder mStringBuilder = new StringBuilder();

        for (int i = 0; i < hashMapLists.size(); i++) {
            String hashMapToJson = JsonUtils.hashMapToJson(hashMapLists.get(i));
            mStringBuilder.append(hashMapToJson).append(",");
        }
        if (mStringBuilder.length() > 0) {
            String substring = mStringBuilder.toString().substring(0, mStringBuilder.toString().lastIndexOf(","));
            content = substring;
        } else {

        }
        return content;
    }

    /**
     * 开户行
     */
    private void enterpriseAccountType(){
        String[] arreaArr = getActivity().getResources().getStringArray(R.array.enterprise_account_type);
        enterprise_account_type.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item,
                android.R.id.text1, arreaArr));
        enterprise_account_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                enterpriseAccountTypeStr = parent.getSelectedItem() + "";
//                String[] arreaArr = getActivity().getResources().getStringArray(R.array.arrea_province);
//                addressStr = arreaArr[position];
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
    }

    /**
     * 企业注册类型
     */
    private void enterpriseType(){
        String[] arreaArr = getActivity().getResources().getStringArray(R.array.enterprise_registration_type);
        enterprise_registration_type.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item,
                android.R.id.text1, arreaArr));
        enterprise_registration_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                enterpriseRegistrationStr = position + "";
//                String[] arreaArr = getActivity().getResources().getStringArray(R.array.arrea_province);
//                addressStr = arreaArr[position];
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
    }

    /**
     * 职业类型
     */
    private void businessLicenseType(){
        String[] arreaArr = getActivity().getResources().getStringArray(R.array.business_license_type);
        business_license_type.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item,
                android.R.id.text1, arreaArr));
        business_license_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                businessLicenseStr = position + "";
                if ("2".equals(businessLicenseStr)){
                    enterprise_org_code_linear.setVisibility(View.GONE);
                }else {
                    enterprise_org_code_linear.setVisibility(View.VISIBLE);
                }
//                String[] arreaArr = getActivity().getResources().getStringArray(R.array.arrea_province);
//                addressStr = arreaArr[position];
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
    }

    /**
     * 职业类型
     */
    private void professionalType(){
        String[] arreaArr = getActivity().getResources().getStringArray(R.array.occupation_type);
        professional_type.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item,
                android.R.id.text1, arreaArr));
        professional_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                professionalStr = parent.getSelectedItem() + "";
//                String[] arreaArr = getActivity().getResources().getStringArray(R.array.arrea_province);
//                addressStr = arreaArr[position];
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
    }

    /**
     * 返回职业类别编号
     * @param type
     */
    private String getOccupationType(String type){
        if ("公务员".equals(type)){
            return "01";
        }else if ("事业单位员工".equals(type)){
            return "02";
        }else if ("企业高管".equals(type)){
            return "03";
        }else if ("私营业主".equals(type)){
            return "04";
        }else if ("金融从业人员".equals(type)){
            return "05";
        }else if ("律师".equals(type)){
            return "06";
        }else if ("会计师".equals(type)){
            return "07";
        }else if ("医护人员".equals(type)){
            return "08";
        }else if ("学生".equals(type)){
            return "09";
        }else if ("公司员工".equals(type)){
            return "10";
        }else if ("商业服务人员".equals(type)){
            return "11";
        }else if ("工人".equals(type)){
            return "12";
        }else if ("农林牧副渔".equals(type)){
            return "13";
        }else if ("军人武警".equals(type)){
            return "14";
        }else if ("文体工作者".equals(type)){
            return "15";
        }else if ("家庭主妇".equals(type)){
            return "16";
        }else if ("退休".equals(type)){
            return "17";
        }else if ("自由职业者".equals(type)){
            return "18";
        }else if ("其他".equals(type)){
            return "19";
        }
        return "01";
    }



    int mYear, mMonth, mDay;
    private DatePickerDialog.OnDateSetListener mdateListener = new DatePickerDialog.OnDateSetListener() {

        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear,
                              int dayOfMonth) {
            mYear = year;
            mMonth = monthOfYear + 1;
            mDay = dayOfMonth;
            String month;
            String day;
            if (mMonth < 10){
                month = "0" + mMonth;
            }else {
                month = "" + mMonth;
            }
            if (mDay < 10){
                day = "0" + mDay;
            }else {
                day = "" + mDay;
            }
            if (isUse == 1){
                //个人身份证有效期
                idcard_date_edit.setText(mYear + "" + month + "" + day);
            }else if (isUse == 2){
                //企业身份证有效期限
                idcard_date_enterprise_edit.setText(mYear + "" + month + "" + day);
            }else if (isUse == 3){
                //营业执照有效期
                business_license_number_time_text.setText(mYear + "" + month + "" + day);
            }else if (isUse == 4){
                //组织机构代码有效期
                exp_orgcode_enterprise_text.setText(mYear + "" + month + "" + day);
            }
        }
    };

    private ArrayList<JsonBean> options1Items = new ArrayList<>();
    private ArrayList<ArrayList<String>> options2Items = new ArrayList<>();
    private ArrayList<ArrayList<ArrayList<String>>> options3Items = new ArrayList<>();

    /**
     * 获取本地数据
     */
    private void initJsonData() {

        /**
         * 注意：assets 目录下的Json文件仅供参考，实际使用可自行替换文件
         * 关键逻辑在于循环体
         *
         * */
        String JsonData = new GetJsonDataUtil().getJson(getActivity(),"province.json");//获取assets目录下的json文件数据

        ArrayList<JsonBean> jsonBean = parseData(JsonData);//用Gson 转成实体


        /**
         * 添加省份数据
         *
         * 注意：如果是添加的JavaBean实体，则实体类需要实现 IPickerViewData 接口，
         * PickerView会通过getPickerViewText方法获取字符串显示出来。
         */
        options1Items = jsonBean;

        for (int i=0;i<jsonBean.size();i++){//遍历省份
            ArrayList<String> CityList = new ArrayList<>();//该省的城市列表（第二级）
            ArrayList<ArrayList<String>> Province_AreaList = new ArrayList<>();//该省的所有地区列表（第三极）

            for (int c=0; c<jsonBean.get(i).getCityList().size(); c++){//遍历该省份的所有城市
                String CityName = jsonBean.get(i).getCityList().get(c).getName();
                CityList.add(CityName);//添加城市

                ArrayList<String> City_AreaList = new ArrayList<>();//该城市的所有地区列表

                //如果无地区数据，建议添加空字符串，防止数据为null 导致三个选项长度不匹配造成崩溃
                if (jsonBean.get(i).getCityList().get(c).getArea() == null
                        ||jsonBean.get(i).getCityList().get(c).getArea().size()==0) {
                    City_AreaList.add("");
                }else {

                    for (int d=0; d < jsonBean.get(i).getCityList().get(c).getArea().size(); d++) {//该城市对应地区所有数据
                        String AreaName = jsonBean.get(i).getCityList().get(c).getArea().get(d);

                        City_AreaList.add(AreaName);//添加该城市所有地区数据
                    }
                }
                Province_AreaList.add(City_AreaList);//添加该省所有地区数据
            }

            /**
             * 添加城市数据
             */
            options2Items.add(CityList);

            /**
             * 添加地区数据
             */
            options3Items.add(Province_AreaList);
        }
    }

    /**
     * Gson 解析
     * @param result
     * @return
     */
    public ArrayList<JsonBean> parseData(String result) {
        ArrayList<JsonBean> detail = new ArrayList<>();
        try {
            JSONArray data = new JSONArray(result);
            Gson gson = new Gson();
            for (int i = 0; i < data.length(); i++) {
                JsonBean entity = gson.fromJson(data.optJSONObject(i).toString(), JsonBean.class);
                detail.add(entity);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return detail;
    }

    private void ShowPickerTwoView() {// 弹出选择器

        OptionsPickerView pvOptions = new OptionsPickerView.Builder(getActivity(), new OptionsPickerView.OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int options2, int options3, View v) {
                //返回的分别是三个级别的选中位置
                provinceAccountStr = options1Items.get(options1).getPickerViewText();
                cityAccountStr = options2Items.get(options1).get(options2);
//                zoneStr = options3Items.get(options1).get(options2).get(options3);

                enterprise_account_text.setText(provinceAccountStr + cityAccountStr);
            }
        })
                .setTitleText("城市选择")
                .setDividerColor(Color.BLACK)
                .setTextColorCenter(Color.BLACK) //设置选中项文字颜色
                .setContentTextSize(20)
                .build();

        /*pvOptions.setPicker(options1Items);//一级选择器*/
        pvOptions.setPicker(options1Items, options2Items);//二级选择器
//        pvOptions.setPicker(options1Items, options2Items,options3Items);//三级选择器
        pvOptions.show();
    }

    private void ShowPickerView() {// 弹出选择器

        OptionsPickerView pvOptions = new OptionsPickerView.Builder(getActivity(), new OptionsPickerView.OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int options2, int options3, View v) {
                //返回的分别是三个级别的选中位置
                provinceStr = options1Items.get(options1).getPickerViewText();
                cityStr = options2Items.get(options1).get(options2);
                zoneStr = options3Items.get(options1).get(options2).get(options3);

                provinceEnterpriseStr = options1Items.get(options1).getPickerViewText();
                cityEnterpriseStr = options2Items.get(options1).get(options2);
                zoneEnterpriseStr = options3Items.get(options1).get(options2).get(options3);

                province_text.setText(provinceStr + cityStr + zoneStr);
                province_enterprise_text.setText(provinceStr + cityStr + zoneStr);
            }
        })
                .setTitleText("城市选择")
                .setDividerColor(Color.BLACK)
                .setTextColorCenter(Color.BLACK) //设置选中项文字颜色
                .setContentTextSize(20)
                .build();

        /*pvOptions.setPicker(options1Items);//一级选择器
        pvOptions.setPicker(options1Items, options2Items);//二级选择器*/
        pvOptions.setPicker(options1Items, options2Items,options3Items);//三级选择器
        pvOptions.show();
    }

}
